package cn.car91.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.widget.Toast;
import cn.car91.utils.CheckStatusUtil;

public class NetworkChangeReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context arg0, Intent arg1) {
		int network = CheckStatusUtil.getConnectedType(arg0);
		switch (network) {
		case ConnectivityManager.TYPE_WIFI:
			Toast.makeText(arg0, "已连接WiFi网络", Toast.LENGTH_SHORT).show();
			break;
		case ConnectivityManager.TYPE_MOBILE:
			switch (CheckStatusUtil.isFastMobileNetwork(arg0)) {
			case 2:
				Toast.makeText(arg0, "已连接2G网络，注意网络使用情况", Toast.LENGTH_SHORT).show();
				break;
			case 3:
				Toast.makeText(arg0, "已连接3G网络，注意网络使用情况", Toast.LENGTH_SHORT).show();	
				break;
			case 4:
				Toast.makeText(arg0, "已连接4G网络，注意网络使用情况", Toast.LENGTH_SHORT).show();
				break;
			default:
				Toast.makeText(arg0, "未知网络", Toast.LENGTH_SHORT).show();
				break;
			}
			break;
		default:
			//Toast.makeText(arg0, "未知网络连接", Toast.LENGTH_SHORT).show();
			break;
		}
	}

}
